// handleSave.js

import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
import axios from "axios";

const handleQuery = (item) => {
  return new Promise((resolve, reject) => {
    axios
      .post("api/activity_history_operate.php?method=save", item)
      .then((response) => {
        if (response.data) {
          ElNotification({
            title: "已保存",
            type: "success",
            duration: 2000,
          });
          resolve(response.data);
        } else {
          ElNotification({
            title: "保存失败",
            type: "warning",
            duration: 2000,
          });
          resolve([]);
        }
      })
      .catch((error) => {
        ElNotification({
          title: "保存失败",
          message: error.message,
          type: "error",
          duration: 2000,
        });
        reject(error);
      });
  });
};

export default handleQuery;
